﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace B303Langf.Parser.AST
{
   public class BoolTypeDenoter : TypeDenoter
   {
      public static readonly BoolTypeDenoter Normal = new BoolTypeDenoter();
      public static readonly BoolTypeDenoter Array = new BoolTypeDenoter( new ArrayIndexer() );

      private ArrayIndexer m_Indexer;

      public BoolTypeDenoter()
      {

      }

      public BoolTypeDenoter( ArrayIndexer arrayIndexer )
      {
         m_Indexer = arrayIndexer;
      }

      public override ArrayIndexer ArrayIndexer
      {
         get
         {
            return m_Indexer;
         }
      }

      public override bool IsArray
      {
         get
         {
            return ArrayIndexer != null;
         }
      }

      public override object Visit( IVisitor v, object obj )
      {
         return v.VisitBoolTypeDenoter( this, obj );
      }

      public override TypeDenoter WithoutArray()
      {
         return new BoolTypeDenoter();
      }

      public override int GetHashCode()
      {
         return GetType().GetHashCode() + IsArray.GetHashCode();
      }

      public override bool Equals( object obj )
      {
         var other = obj as BoolTypeDenoter;
         if( other != null )
         {
            return IsArray == other.IsArray;
         }
         return false;
      }
   }
}
